package process_demo.review.wait_notify;

import java.util.concurrent.TimeUnit;

/**
 * @author haomin
 * @date 2022/09/12 12:11
 **/
public class Demo4 {
    static Object o = new Object();
    static class MyThread extends Thread{
        @Override
        public void run() {
            synchronized (o){
                System.out.println("先执行notify");
                o.notify();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();
        t.start();


        TimeUnit.SECONDS.sleep(3);
        synchronized (o){
            System.out.println("wait将一直等待被唤醒");
            o.wait();
        }
    }
}